package thread;

public class PrintNumCh {
	int count = 0;
	int num = 1;
	int ch = 0;

	public static void main(String[] args) {
		final PrintNumCh t = new PrintNumCh();
		new Thread() {
			public void run() {
				try {
					t.printCh();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}.start();
		new Thread() {
			public void run() {
				try {
					t.printNum();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}.start();
	}

	public synchronized void printNum() throws InterruptedException {
		while (num < 53) {
			while (count % 3 == 2) {
				wait();
			}
			System.out.println(num++);
			System.out.println(num++);
			count += 2;
			notifyAll();
		}
	}

	public synchronized void printCh() throws InterruptedException {
		while (ch < 26) {
			while (count % 3 != 2) {
				wait();
			}
			System.out.println((char) ('A' + ch));
			ch++;
			count++;
			notifyAll();
		}
	}
}
